home *** CD-ROM | disk | FTP | other *** search
/ Internet.Works 39 / Issue 39.iso / pc / PCSoftware / AceHTML 4.0 / AceHTML4Pro.exe / %MAINDIR% / ScriptDef / Select A Month.sd < prev    next >
Encoding:
INI File  |  2000-08-31  |  5.0 KB  |  183 lines

  1. [SUBJECT]
  2. Description=Builds calendar for a month
  3. ImageIndex=-1
  4. Folder=Quick JavaScript
  5.  
  6.  
  7. [HEAD_TEXT]
  8. ;<SCRIPT LANGUAGE="JavaScript">
  9. ;<!-- Begin
  10. ;function setToday() {
  11. ;var now   = new Date();
  12. ;var day   = now.getDate();
  13. ;var month = now.getMonth();
  14. ;var year  = now.getYear();
  15. ;if (year < 2000)    // Y2K Fix, Isaac Powell
  16. ;year = year + 1900; // http://onyx.idbsu.edu/~ipowell
  17. ;this.focusDay = day;
  18. ;document.calControl.month.selectedIndex = month;
  19. ;document.calControl.year.value = year;
  20. ;displayCalendar(month, year);
  21. ;}
  22. ;function isFourDigitYear(year) {
  23. ;if (year.length != 4) {
  24. ;alert ("Sorry, the year must be four-digits in length.");
  25. ;document.calControl.year.select();
  26. ;document.calControl.year.focus();
  27. ;} else { return true; }
  28. ;}
  29. ;function selectDate() {
  30. ;var year  = document.calControl.year.value;
  31. ;if (isFourDigitYear(year)) {
  32. ;var day   = 0;
  33. ;var month = document.calControl.month.selectedIndex;
  34. ;displayCalendar(month, year);
  35. ;    }
  36. ;}
  37. ;
  38. ;function setPreviousYear() {
  39. ;var year  = document.calControl.year.value;
  40. ;if (isFourDigitYear(year)) {
  41. ;var day   = 0;
  42. ;var month = document.calControl.month.selectedIndex;
  43. ;year--;
  44. ;document.calControl.year.value = year;
  45. ;displayCalendar(month, year);
  46. ;   }
  47. ;}
  48. ;function setPreviousMonth() {
  49. ;var year  = document.calControl.year.value;
  50. ;if (isFourDigitYear(year)) {
  51. ;var day   = 0;
  52. ;var month = document.calControl.month.selectedIndex;
  53. ;if (month == 0) {
  54. ;month = 11;
  55. ;if (year > 1000) {
  56. ;year--;
  57. ;document.calControl.year.value = year;
  58. ;}
  59. ;} else { month--; }
  60. ;document.calControl.month.selectedIndex = month;
  61. ;displayCalendar(month, year);
  62. ;   }
  63. ;}
  64. ;function setNextMonth() {
  65. ;var year  = document.calControl.year.value;
  66. ;if (isFourDigitYear(year)) {
  67. ;var day   = 0;
  68. ;var month = document.calControl.month.selectedIndex;
  69. ;if (month == 11) {
  70. ;month = 0;
  71. ;year++;
  72. ;document.calControl.year.value = year;
  73. ;} else { month++; }
  74. ;document.calControl.month.selectedIndex = month;
  75. ;displayCalendar(month, year);
  76. ;   }
  77. ;}
  78. ;function setNextYear() {
  79. ;var year = document.calControl.year.value;
  80. ;if (isFourDigitYear(year)) {
  81. ;var day = 0;
  82. ;var month = document.calControl.month.selectedIndex;
  83. ;year++;
  84. ;document.calControl.year.value = year;
  85. ;displayCalendar(month, year);
  86. ;   }
  87. ;}
  88. ;function displayCalendar(month, year) {
  89. ;month = parseInt(month);
  90. ;year = parseInt(year);
  91. ;var i = 0;
  92. ;var days = getDaysInMonth(month+1,year);
  93. ;var firstOfMonth = new Date (year, month, 1);
  94. ;var startingPos = firstOfMonth.getDay();
  95. ;days += startingPos;
  96. ;document.calButtons.calPage.value  =   " Su Mo Tu We Th Fr Sa";
  97. ;document.calButtons.calPage.value += "\n --------------------";
  98. ;for (i = 0; i < startingPos; i++) {
  99. ;if ( i%7 == 0 ) document.calButtons.calPage.value += "\n ";
  100. ;document.calButtons.calPage.value += "   ";
  101. ;}
  102. ;for (i = startingPos; i < days; i++) {
  103. ;if ( i%7 == 0 ) document.calButtons.calPage.value += "\n ";
  104. ;if (i-startingPos+1 < 10)
  105. ;document.calButtons.calPage.value += "0";
  106. ;document.calButtons.calPage.value += i-startingPos+1;
  107. ;document.calButtons.calPage.value += " ";
  108. ;}
  109. ;for (i=days; i<42; i++)  {
  110. ;if ( i%7 == 0 ) document.calButtons.calPage.value += "\n ";
  111. ;document.calButtons.calPage.value += "   ";
  112. ;}
  113. ;document.calControl.Go.focus();
  114. ;}
  115. ;function getDaysInMonth(month,year)  {
  116. ;var days;
  117. ;if (month==1 || month==3 || month==5 || month==7 || month==8 || month==10 || month==12)  days=31;
  118. ;else if (month==4 || month==6 || month==9 || month==11) days=30;
  119. ;else if (month==2)  {
  120. ;if (isLeapYear(year)) { days=29; }
  121. ;else { days=28; }
  122. ;}
  123. ;return (days);
  124. ;}
  125. ;function isLeapYear (Year) {
  126. ;if (((Year % 4)==0) && ((Year % 100)!=0) || ((Year % 400)==0)) {
  127. ;return (true);
  128. ;} else { return (false); }
  129. ;}
  130. ;// End -->
  131. ;</SCRIPT>
  132.  
  133.  
  134. [BODY_TAG]
  135. ;onLoad="setToday()"
  136.  
  137. [BODY_TEXT]
  138. ;
  139. ;<CENTER>
  140. ;<H2>`Caption`</H2>
  141. ;<FORM NAME="calControl" onSubmit="return false;">
  142. ;<TABLE CELLPADDING=0 CELLSPACING=0 BORDER=0>
  143. ;<TR><TD COLSPAN=7>
  144. ;<CENTER>
  145. ;<SELECT NAME="month" onChange="selectDate()">
  146. ;<OPTION>January
  147. ;<OPTION>February
  148. ;<OPTION>March
  149. ;<OPTION>April
  150. ;<OPTION>May
  151. ;<OPTION>June
  152. ;<OPTION>July
  153. ;
  154. ;<OPTION>August
  155. ;<OPTION>September
  156. ;<OPTION>October
  157. ;<OPTION>November
  158. ;<OPTION>December
  159. ;</SELECT>
  160. ;<INPUT NAME="year" TYPE=TEXT SIZE=4 MAXLENGTH=4>
  161. ;<INPUT TYPE="button" NAME="Go" value="Build!" onClick="selectDate()">
  162. ;</CENTER>
  163. ;</TD>
  164. ;</TR>
  165. ;</FORM>
  166. ;<FORM NAME="calButtons">
  167. ;<TR><TD align="center"><textarea FONT="Courier" NAME="calPage" WRAP=no ROWS=8 COLS=22></textarea></TD><TR><TD><CENTER>
  168. ;<INPUT TYPE=BUTTON NAME="previousYear" VALUE=" <<  "    onClick="setPreviousYear()">
  169. ;<INPUT TYPE=BUTTON NAME="previousYear" VALUE="  <  "    onClick="setPreviousMonth()">
  170. ;<INPUT TYPE=BUTTON NAME="previousYear" VALUE="Today"    onClick="setToday()">
  171. ;<INPUT TYPE=BUTTON NAME="previousYear" VALUE="  >  "    onClick="setNextMonth()">
  172. ;<INPUT TYPE=BUTTON NAME="previousYear" VALUE="  >> "    onClick="setNextYear()">
  173. ;</CENTER></TD></TR>
  174. ;</TABLE></FORM></FONT>
  175. ;
  176.  
  177.  
  178. [`Caption`]
  179. Kind=S
  180. Value=Select-A-Month
  181.  
  182.  
  183.